using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SalesHistoryMap : EntityTypeConfiguration<SalesHistory>
    {
        public SalesHistoryMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.Acct)
                .HasMaxLength(40);

            this.Property(t => t.Invoice)
                .HasMaxLength(15);

            this.Property(t => t.Item)
                .HasMaxLength(10);

            this.Property(t => t.Customer)
                .HasMaxLength(30);

            this.Property(t => t.Salesman)
                .HasMaxLength(30);

            this.Property(t => t.Project)
                .HasMaxLength(20);

            this.Property(t => t.Currency)
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.DocumentType)
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.InvoiceType)
                .IsFixedLength()
                .HasMaxLength(20);

            this.Property(t => t.DocumentNumber)
                .IsFixedLength()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("SalesHistory");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.Acct).HasColumnName("Acct");
            this.Property(t => t.Invoice).HasColumnName("Invoice");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.CustomerNo).HasColumnName("CustomerNo");
            this.Property(t => t.Item).HasColumnName("Item");
            this.Property(t => t.Customer).HasColumnName("Customer");
            this.Property(t => t.SalesmanNo).HasColumnName("SalesmanNo");
            this.Property(t => t.Salesman).HasColumnName("Salesman");
            this.Property(t => t.QTY).HasColumnName("QTY");
            this.Property(t => t.Project).HasColumnName("Project");
            this.Property(t => t.Currency).HasColumnName("Currency");
            this.Property(t => t.Subtotal).HasColumnName("Subtotal");
            this.Property(t => t.Total).HasColumnName("Total");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.cost1).HasColumnName("cost1");
            this.Property(t => t.cost2).HasColumnName("cost2");
            this.Property(t => t.DocumentType).HasColumnName("DocumentType");
            this.Property(t => t.InvoiceType).HasColumnName("InvoiceType");
            this.Property(t => t.DocumentNumber).HasColumnName("DocumentNumber");
        }
    }
}
